
var particleSystem : ParticleEmitter;
var particleGameObject : GameObject;
var characterMotor : CharacterMotor;

function Start() {
	characterMotor = GetComponent(CharacterMotor);
	//Aim(180);
}

//Metodo de colision que envia el mensaje de congelese.
function OnCollisionEnter(collision:Collision){
    collision.gameObject.SendMessage("freeze");
}

function ExtinguisherOn() {
	particleSystem.emit = true;
}

function ExtinguisherOff() {
	particleSystem.emit = false;
}

function Aim(aimAngle : float) {
	particleGameObject.transform.rotation.z = aimAngle;
}
function Update() {

	if(Input.GetAxis("Horizontal") >= 0.2) {
		particleSystem.localVelocity.x = -15;
		if(characterMotor.IsJumping()) {
		//Aim(90);
		particleSystem.localVelocity.x = 15;
		particleSystem.localVelocity.z = 15;
		Debug.Log("Jumping and moving to the right");
		}
		//Aim(180);
	}
		
	if(Input.GetAxis("Horizontal") <= -0.2) {
		particleSystem.localVelocity.x = 15;
		if(characterMotor.IsJumping()) {
		//Aim(90);
		particleSystem.localVelocity.x = -15;
		particleSystem.localVelocity.z = 15;
		Debug.Log("Jumping and moving to the left");
		}
		//particleSystem.transform.rotation.y = 0;
		//Aim(0);
	}
	
	if(characterMotor.IsJumping()) {
		//Aim(90);
	}
}